﻿@model ConfigurationModel
@inject Nop.Core.IWebHelper webHelper

@{
    Layout = "_ConfigurePlugin";
    var hideSearchBlock = Model.GoogleAuthenticatorSearchModel.HideSearchBlock;
}

<form asp-controller="GoogleAuthenticator" asp-action="Configure" method="post">    
    <selection class="content">
        <div class="container-fluid">
            <div class="card card-default">
                <div class="card-body">
                    <p>
                        @Html.Raw(string.Format(T("Plugins.MultiFactorAuth.GoogleAuthenticator.Instructions").Text, webHelper.GetStoreLocation()))
                    </p>
                    <hr/>
                    <div class="form-group row">                    
                        <div class="col-md-3">
                            <nop-label asp-for="BusinessPrefix" />
                        </div>
                        <div class="col-md-9">
                            <nop-editor asp-for="BusinessPrefix" />
                            <span asp-validation-for="BusinessPrefix"></span>
                        </div>
                    </div>
                    <div class="form-group row">                    
                        <div class="col-md-3">
                            <nop-label asp-for="QRPixelsPerModule" />
                        </div>
                        <div class="col-md-9">
                            <nop-editor asp-for="QRPixelsPerModule" />
                            <span asp-validation-for="QRPixelsPerModule"></span>
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-md-9 offset-md-3">
                            <button type="submit" name="save" class="btn btn-primary">@T("Admin.Common.Save")</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="card card-default card-search">
                <div class="card-body">
                    <div class="row search-row @(!Model.GoogleAuthenticatorSearchModel.HideSearchBlock ? "opened" : "")" data-hideAttribute="@GoogleAuthenticatorDefaults.HideSearchBlockAttribute">
                        <div class="search-text">@T("Admin.Common.Search")</div>
                        <div class="icon-search"><i class="fas fa-magnifying-glass" aria-hidden="true"></i></div>
                        <div class="icon-collapse"><i class="far fa-angle-@(!hideSearchBlock ? "up" : "down")" aria-hidden="true"></i></div>
                    </div>
                    <div class="search-body @(Model.GoogleAuthenticatorSearchModel.HideSearchBlock ? "closed" : "")">
                        <div class="row">
                            <div class="col-md-5">
                                <div class="form-group row">
                                    <div class="col-md-4">
                                        <nop-label asp-for="@Model.GoogleAuthenticatorSearchModel.SearchEmail" />
                                    </div>
                                    <div class="col-md-8">
                                        <nop-editor asp-for="@Model.GoogleAuthenticatorSearchModel.SearchEmail" />
                                    </div>
                                </div>                            
                            </div>
                        </div>
                        <div class="row">
                            <div class="text-center col-12">
                                <button type="button" id="search-customers" class="btn btn-primary btn-search">
                                    <i class="fas fa-magnifying-glass"></i>
                                    @T("Admin.Common.Search")
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="card card-default">
                <div class="card-body">
                    @await Html.PartialAsync("Table", new DataTablesModel
                    {
                        Name = "googleguthenticator-grid",
                        SearchButtonId = "search-customers",
                        UrlRead = new DataUrl("GoogleAuthenticatorList", "GoogleAuthenticator", null),
                        UrlDelete = new DataUrl("GoogleAuthenticatorDelete", "GoogleAuthenticator", null),
                        Length = Model.GoogleAuthenticatorSearchModel.PageSize,
                        LengthMenu = Model.GoogleAuthenticatorSearchModel.AvailablePageSizes,
                        Filters = new List<FilterParameter>
                        {
                            new FilterParameter(nameof(GoogleAuthenticatorSearchModel.SearchEmail), nameof(GoogleAuthenticatorSearchModel))
                        },
                        ColumnCollection = new List<ColumnProperty>
                        {
                            new ColumnProperty(nameof(GoogleAuthenticatorModel.Customer))
                            {
                                Title = T("Plugins.MultiFactorAuth.GoogleAuthenticator.Fields.Customer").Text
                            },
                            new ColumnProperty(nameof(GoogleAuthenticatorModel.Id))
                            {
                                Title = T("Admin.Common.Delete").Text,
                                Width = "100",
                                ClassName =  NopColumnClassDefaults.Button,
                                Render = new RenderButtonRemove(T("Admin.Common.Delete").Text)
                            }
                        }
                    })
                </div>
            </div>
        </div>
    </selection>
</form>